package com.fay.mymiaosha.response;

/**
 * @Title:
 * @Description:
 * @Author Fay Wang
 * @Date 2022/3/15 11:01
 * @Version 1.0
 */
public enum EmBizError implements CommonError{
    // generic err type 10001   int在序列化的时候会转换成只有个位数的数字
    PARAMETER_VALIDATION_ERROR(10001, "参数不合法"),
    UNKNOWN_ERROR(10002, "未知错误"),

    // 20000 means user_info error   需要全局统一的错误码的流转
    USER_NOT_EXIST(20001, "用户不存在"),
    USER_LOGIN_FAIL(20002, "用户名或密码错误"),

    //30000开头，交易相关的错误
    STOCK_NOT_ENOUGH(30001,"库存不足"),
    ;


    private int errCode;
    private String errMsg;

    EmBizError(int errCode, String errMsg) {
        this.errCode = errCode;
        this.errMsg = errMsg;
    }

    @Override
    public int gerErrCode() {
        return this.errCode;
    }

    @Override
    public String getErrMsg() {
        return this.errMsg;
    }

    // 自定义改动errMsg
    @Override
    public CommonError setErrMsg(String errMsg) {
        this.errMsg = errMsg;
        return this;
    }
}
